package com.heima.behavior.controller;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.behavior.dto.LikesBehaviorDto;
import com.heima.model.behavior.dto.ReadBehaviorDto;
import com.heima.model.behavior.dto.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/v1/")
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * 点赞行为
     * @param likesBehaviorDto
     * @param request
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto likesBehaviorDto, HttpServletRequest request){
        return behaviorService.likesBehavior(likesBehaviorDto,request);
    }

    /**
     * 喜欢行为
     * @param unLikesBehaviorDto
     * @param request
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody UnLikesBehaviorDto unLikesBehaviorDto, HttpServletRequest request) {
        return behaviorService.unLikesBehavior(unLikesBehaviorDto, request);
    }

    /**
     * 阅读行为
     * @param readBehaviorDto
     * @param request
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto readBehaviorDto, HttpServletRequest request) {
        return behaviorService.readBehavior(readBehaviorDto, request);
    }
}
